import {provinces,
        areas,
        stage,
        getSchoolList,
        subjectsBySchoolId,
        gradesBySchoolId,
        creatSchool,
        dictionaryvalue,
        updateSchool,
        deleteSchool,
        schoolDetail,
        agents,
        schoolYear,
        exportSchoolList,
        userInfo
    } from '@/api/schoolApi'
const schoolManage = {
    namespaced: true,
    state: {
      gradeData: [],
      subjectData: [],
      dict: '',
      stageData: [],
      schoolYearData: [],
      agentData: []
    },
    getters: {
    },
    mutations: {
    },
    actions: {
      Provinces ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          provinces(params).then(res => {
                resolve(res)
            })
        })
      },
      Areas ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          areas(params).then(res => {
                resolve(res)
            })
        })
      },
      // 获取学段
      Stage ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          stage(params).then(res => {
              resolve(res)
          })
        })
      },
      // 获取学校
      GetSchoolList ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          getSchoolList(params).then(res => {
              resolve(res)
          })
        })
      },
      // 获取学科
      SubjectsBySchoolId ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          subjectsBySchoolId(params).then(res => {
              resolve(res)
          })
        })
      },
      // 获取年级
      GradesBySchoolId ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          gradesBySchoolId(params).then(res => {
              resolve(res)
          })
        })
      },
      // 创建学校
      CreatSchool ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          creatSchool(params).then(res => {
              resolve(res)
          })
        })
      },
      // 字典数据
      Dictionaryvalue ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          dictionaryvalue(params).then(res => {
              resolve(res)
          })
        })
      },
      // 更新学校
      UpdateSchool ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          updateSchool(params).then(res => {
              resolve(res)
          }).catch(res => {
            reject(res)
          })
        })
      },
      // 删除学校
      DeleteSchool ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          deleteSchool(params).then(res => {
              resolve(res)
          })
        })
      },
      // 获取学校详情
      SchoolDetail ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          schoolDetail(params).then(res => {
              resolve(res)
          })
        })
      },
      // 代理商
      Agents ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          agents(params).then(res => {
              resolve(res)
          })
        })
      },
      // 学年
      SchoolYear ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          schoolYear(params).then(res => {
              resolve(res)
          })
        })
      },
      // exportSchoolList导出
      ExportSchoolList ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          exportSchoolList(params).then(res => {
              resolve(res)
          })
        })
      },
      UserInfo ({state, commit, dispatch}, params) {
        return new Promise((resolve, reject) => {
          userInfo(params).then(res => {
              resolve(res)
          }).catch(res => {
            reject(res)
          })
        })
      }
    }
}
export default schoolManage
